Skip to content

don't emit unused_results lint for tuples of "trivial" types #153191

Open
WaffleLapkin wants to merge 2 commits intorust-lang:mainfrom
WaffleLapkin:shouldnt_use_trivial_tuples
Open

don't emit unused_results lint for tuples of "trivial" types #153191
WaffleLapkin wants to merge 2 commits intorust-lang:mainfrom
WaffleLapkin:shouldnt_use_trivial_tuples

Conversation

@WaffleLapkin
Copy link
Member

@WaffleLapkin WaffleLapkin commented Feb 27, 2026

r? @jdonszelmann
Fixes #153144.

So it turns out #153018 had a sneaky behavior change in the way tuples are handled and the old behavior wasn't tested.

Consider these tuples:

((), ());
((), 1);

Neither of them is must_use, so they are potential candidates for unused_results. So the question is whatever said tuples are considered "trivial" and thus if they end up emitting unused_results or not.

Here is a comparison table between PRs:



stableAfter #153018After this PR
((), ()); // trivial
((), 1); // trivial
((), ()); //~ warn: unused_results
((), 1); //~ warn: unused_results
((), ()); // trivial
((), 1); //~ warn: unused_results

tuples are trivial if any of their fields are trivial

tuples are never trivial

tuples are trivial if all of their fields are trivial

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 27, 2026
@WaffleLapkin WaffleLapkin force-pushed the shouldnt_use_trivial_tuples branch from 621c007 to 8958cb9 Compare February 27, 2026 16:41
@jdonszelmann
Copy link
Contributor

@bors r+ rollup

@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 2, 2026

📌 Commit 8958cb9 has been approved by jdonszelmann

It is now in the queue for this repository.

@rust-bors rust-bors bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 2, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Mar 2, 2026
…tuples, r=jdonszelmann

  don't emit `unused_results` lint for tuples of "trivial" types

r? @jdonszelmann
Fixes rust-lang#153144.

So it turns out rust-lang#153018 had a sneaky behavior change in the way tuples are handled and the old behavior wasn't tested.

Consider these tuples:

```rust
((), ());
((), 1);
```

Neither of them is `must_use`, so they are potential candidates for `unused_results`. So the question is whatever said tuples are considered "trivial" and thus if they end up emitting `unused_results` or not.

Here is a comparison table between PRs:
<table>
<tr><td>stable</td><td>After rust-lang#153018</td><td>After this PR</td></tr><tr><td>

```rust
((), ()); // trivial
((), 1); // trivial
```
</td>
<td>

```rust
((), ()); //~ warn: unused_results
((), 1); //~ warn: unused_results
```
</td>
<td>

```rust
((), ()); // trivial
((), 1); //~ warn: unused_results
```
</td>
</tr>
  <tr>
    <td>

tuples are trivial if **any** of their fields are trivial
    </td>
    <td>

tuples are never trivial
    </td>
    <td>

tuples are trivial if **all** of their fields are trivial
    </td>
  </tr>
</table>
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Mar 2, 2026
…tuples, r=jdonszelmann

  don't emit `unused_results` lint for tuples of "trivial" types

r? @jdonszelmann
Fixes rust-lang#153144.

So it turns out rust-lang#153018 had a sneaky behavior change in the way tuples are handled and the old behavior wasn't tested.

Consider these tuples:

```rust
((), ());
((), 1);
```

Neither of them is `must_use`, so they are potential candidates for `unused_results`. So the question is whatever said tuples are considered "trivial" and thus if they end up emitting `unused_results` or not.

Here is a comparison table between PRs:
<table>
<tr><td>stable</td><td>After rust-lang#153018</td><td>After this PR</td></tr><tr><td>

```rust
((), ()); // trivial
((), 1); // trivial
```
</td>
<td>

```rust
((), ()); //~ warn: unused_results
((), 1); //~ warn: unused_results
```
</td>
<td>

```rust
((), ()); // trivial
((), 1); //~ warn: unused_results
```
</td>
</tr>
  <tr>
    <td>

tuples are trivial if **any** of their fields are trivial
    </td>
    <td>

tuples are never trivial
    </td>
    <td>

tuples are trivial if **all** of their fields are trivial
    </td>
  </tr>
</table>
rust-bors bot pushed a commit that referenced this pull request Mar 2, 2026
…uwer

Rollup of 5 pull requests

Successful merges:

 - #151962 (Fix next-solver ICE on PointeeSized goals)
 - #153161 (Rejig `rustc_with_all_queries!`)
 - #152164 (Lint unused features)
 - #153191 (  don't emit `unused_results` lint for tuples of "trivial" types )
 - #153273 (vec/mod.rs: add missing period in "ie." in docs)
rust-bors bot pushed a commit that referenced this pull request Mar 2, 2026
…uwer

Rollup of 5 pull requests

Successful merges:

 - #151962 (Fix next-solver ICE on PointeeSized goals)
 - #153161 (Rejig `rustc_with_all_queries!`)
 - #152164 (Lint unused features)
 - #153191 (  don't emit `unused_results` lint for tuples of "trivial" types )
 - #153273 (vec/mod.rs: add missing period in "ie." in docs)
rust-bors bot pushed a commit that referenced this pull request Mar 2, 2026
…uwer

Rollup of 5 pull requests

Successful merges:

 - #151962 (Fix next-solver ICE on PointeeSized goals)
 - #153161 (Rejig `rustc_with_all_queries!`)
 - #152164 (Lint unused features)
 - #153191 (  don't emit `unused_results` lint for tuples of "trivial" types )
 - #153273 (vec/mod.rs: add missing period in "ie." in docs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

unused_result lint generates warnings for tuples of "trivial" types (such as ((), ()))

3 participants